/*
 * @Author: zingpp
 * @Date: 2025-06-20 14:56:48
 * @LastEditors: zingpp
 * @LastEditTime: 2025-06-20 15:10:55
 * @FilePath: \cool-server\src\modules\customer-service\entities\message.entity.ts
 * @Description: 
 * 
 * Copyright (c) 2025 by 用户/公司名, All Rights Reserved. 
 */
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { CustomerServiceSession } from './session.entity';
import { User } from '../../user/user.entity';
import { CustomerServiceAgent } from './agent.entity';

@Entity('customer_service_message')
export class CustomerServiceMessage {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => CustomerServiceSession)
  @JoinColumn({ name: 'sessionId' })
  session: CustomerServiceSession;

  @Column({ type: 'enum', enum: ['user', 'agent'] })
  senderType: 'user' | 'agent';

  @ManyToOne(() => User, { nullable: true })
  @JoinColumn({ name: 'userId' })
  user: User;

  @ManyToOne(() => CustomerServiceAgent, { nullable: true })
  @JoinColumn({ name: 'agentId' })
  agent: CustomerServiceAgent;

  @Column('text')
  content: string;

  @Column({ default: false })
  isRead: boolean;

  @CreateDateColumn()
  createdAt: Date;
} 